﻿using UnityEngine;
using System.Collections;

public class KeyboardScroll : MonoBehaviour {
	
	UIScrollBar hScrollBar;
	UIScrollBar vScrollBar;
	
	public float keyboardSensitivity = 1;
	

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		Vector2 keyDelta = Vector2.zero;
		keyDelta.Set(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
		if( keyDelta == Vector2.zero)
			return ;
		
		keyDelta *= Time.deltaTime * keyboardSensitivity;
		hScrollBar.value += keyDelta.x;
		vScrollBar.value += keyDelta.y;
	}
	
	void Awake()
	{
		hScrollBar = GetComponent<UIDraggablePanel>().horizontalScrollBar;
		vScrollBar = GetComponent<UIDraggablePanel>().verticalScrollBar;
	}
	
}
